package com.eig.student.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.eig.common.entity.system.TbMember;
import com.eig.common.vo.Result;
import com.eig.student.service.StudentService;
import com.eig.student.vo.Studentvo;
import com.eig.web.dao.TbMemberDao;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.File;

/**
 * @author ：liu666
 * @date ：
 * @description：
 * @modified By：
 * @version:
 */
@Service("tOrderService")
public class StudentServiceImpl implements StudentService {
    @Resource
    private TbMemberDao tbMemberDao;


    @Override
    public Result<TbMember> getMember(String mobile) {
        QueryWrapper<TbMember> wrapper = new QueryWrapper<>();
        wrapper.eq("mobile", mobile);
        TbMember tbMember = tbMemberDao.selectOne(wrapper);
        return new Result<TbMember>(2000,"",tbMember);
    }

    @Override
    public Result updMember(Studentvo studentvo) {
        UpdateWrapper<TbMember> wrapper = new UpdateWrapper<>();
        wrapper.eq("mobile",studentvo.getMobile());
        if(studentvo.getSex()!=""&&studentvo.getSex()!=null){
            wrapper.set("sex",studentvo.getSex());
        }
        if(studentvo.getAge()!=""&&studentvo.getAge()!=null){
            wrapper.set("age",studentvo.getAge());
        }
        if(studentvo.getAvatar()!=""&&studentvo.getAvatar()!=null){
            wrapper.set("avatar",studentvo.getAvatar());
        }
        if(studentvo.getNickname()!=""&&studentvo.getNickname()!=null){
            wrapper.set("nickname",studentvo.getNickname());
        }
        int update = tbMemberDao.update(null, wrapper);
        if(update==1){
            return new Result(2000,"修改成功",null);
        }else {
            return new Result(2000,"修改失败",null);
        }
    }

    @Override
    public Result uploadMsg(File file) {
        return null;
    }
}
